package main

import "fmt"

//map 可以动态增长 key value，切片不行必须 append
func main() {
	var map1 map[string]map[string]string
	map1 = make(map[string]map[string]string) //make map 不需要加size
	map1["hb"] = map[string]string{"nickname": "sbw", "pwd": "1111"}
	map1["cy"] = map[string]string{"nickname": "yu", "pwd": "3333"}
	modifyUser(map1)
	fmt.Println(map1)
}
func modifyUser(map1 map[string]map[string]string) {
	var userName string
	var password string
	fmt.Println("请输入用户名")
	fmt.Scanln(&userName)
	_, ok := map1[userName]
	if ok {
		fmt.Println("请输入修改后的密码")
		fmt.Scanln(&password)
		map1[userName]["pwd"] = password
	} else {
		fmt.Println("用户名不存在")
	}
}
